﻿using Microsoft.EntityFrameworkCore;
using MyProduce.Produce;
using Volo.Abp;
using Volo.Abp.EntityFrameworkCore.Modeling;

namespace MyProduce.EntityFrameworkCore;

public static class MyProduceDbContextModelCreatingExtensions
{
    public static void ConfigureMyProduce(
        this ModelBuilder builder)
    {
        Check.NotNull(builder, nameof(builder));

        /* Configure all entities here. Example:

        builder.Entity<Question>(b =>
        {
            //Configure table & schema name
            b.ToTable(MyProduceDbProperties.DbTablePrefix + "Questions", MyProduceDbProperties.DbSchema);

            b.ConfigureByConvention();

            //Properties
            b.Property(q => q.Title).IsRequired().HasMaxLength(QuestionConsts.MaxTitleLength);

            //Relations
            b.HasMany(question => question.Tags).WithOne().HasForeignKey(qt => qt.QuestionId);

            //Indexes
            b.HasIndex(q => q.CreationTime);
        });
        */
        //配种方式
        builder.Entity<Breedingpattern>(b =>
        {
            b.ToTable("BreedingPattern");
            b.ConfigureByConvention();
            b.Property(x => x.BreedingName).IsRequired().HasMaxLength(50);
        });
        //转舍
        builder.Entity<Camp>(b =>
        {
            b.ToTable("Camp");
            b.ConfigureByConvention();
            b.Property(x => x.Transfertobuilding).IsRequired().HasMaxLength(50);
            b.Property(x => x.Variety).IsRequired().HasMaxLength(50);
        });

        //配种
        builder.Entity<EweBreeding>(b =>
        {
            b.ToTable("EweBreeding");
            b.ConfigureByConvention();
            b.Property(x => x.Transfertobuilding).IsRequired().HasMaxLength(50);
        });

        //生长阶段
        builder.Entity<Growthstage>(n =>
        {
            n.ToTable("GrowthStage");
            n.ConfigureByConvention();
            n.Property(x => x.GrowthName).IsRequired().HasMaxLength(50);
        });

        //在场状态
        builder.Entity<Presence>(x =>
        {
            x.ToTable("Presence");
            x.ConfigureByConvention();
            x.Property(x => x.PresenceName).IsRequired().HasMaxLength(50);
        });

        //转舍类型
        builder.Entity<RoundType>(x =>
        {
            x.ToTable("RoundType");
            x.ConfigureByConvention();
            x.Property(x => x.RoundName).IsRequired().HasMaxLength(50);
        });

        //羊只档案
        builder.Entity<SheepManagement>(x =>
        {
            x.ToTable("SheepManagement");
            x.ConfigureByConvention();
            x.Property(x => x.Variety).IsRequired().HasMaxLength(50);
        });
        //羊只档案
        builder.Entity<SheepManagement>(x =>
        {
            x.ToTable("SheepManagement");
            x.ConfigureByConvention();
            x.Property(x => x.Variety).IsRequired().HasMaxLength(50);
        });
        //种母历史记录
        builder.Entity<Germlinehistoryrecords>(x =>
        {
            x.ToTable("Germlinehistoryrecords");
            x.ConfigureByConvention();
            x.Property(x => x.Variety).IsRequired().HasMaxLength(50);
        });
        //妊检结果
        builder.Entity<Pregnancytestresult>(x =>
        {
            x.ToTable("Pregnancytestresult");
            x.ConfigureByConvention();
            x.Property(x => x.PregnancyName).IsRequired().HasMaxLength(50);
        });
        //种母妊检
        builder.Entity<Prenatal>(x =>
        {
            x.ToTable("Prenatal");
            x.ConfigureByConvention();
            x.Property(x => x.Variety).IsRequired().HasMaxLength(50);
        });
        //分娩
        builder.Entity<Seedbirth>(x =>
        {
            x.ToTable("Seedbirth");
            x.ConfigureByConvention();
            x.Property(x => x.Variety).IsRequired().HasMaxLength(50);
        });
        //种母断奶
        builder.Entity<Seedweaning>(x =>
        {
            x.ToTable("Seedweaning");
            x.ConfigureByConvention();
            x.Property(x => x.Variety).IsRequired().HasMaxLength(50);
        });
        //羔羊断奶
        builder.Entity<Weaned>(x =>
        {
            x.ToTable("Weaned");
            x.ConfigureByConvention();
            x.Property(x => x.Wbuildings).IsRequired().HasMaxLength(50);
        });
        //羔羊断奶
        builder.Entity<Weaned>(x =>
        {
            x.ToTable("Weaned");
            x.ConfigureByConvention();
            x.Property(x => x.Wbuildings).IsRequired().HasMaxLength(50);
        });
        //转种
        builder.Entity<Transplanting>(x =>
        {
            x.ToTable("Transplanting");
            x.ConfigureByConvention();
            x.Property(x => x.Tearbugles).IsRequired().HasMaxLength(50);
        });
        //出生状态
        builder.Entity<Birth>(x =>
        {
            x.ToTable("Birth");
            x.ConfigureByConvention();
            x.Property(x => x.BirthName).IsRequired().HasMaxLength(50);
        });
    }
}
